#ifndef CODEEDITORANIMATOR_H
#define CODEEDITORANIMATOR_H

#include <QtCore>
#include <QtGui>

namespace CodeEdit {

class CodeEditorAnimator : public QObject
{
    Q_OBJECT

public:
    CodeEditorAnimator(QObject *parent);

    inline void setPosition(int position) { _position = position; }
    inline int position() const { return _position; }

    void setData(QFont f, QPalette pal, const QString &text);

    void draw(QPainter *p, const QPointF &pos);
    QRectF rect() const;

    inline qreal value() const { return _value; }
    inline QPointF lastDrawPos() const { return _lastDrawPos; }

    void finish();

    bool isRunning() const;

signals:
    void updateRequest(int position, QPointF lastPos, QRectF rect);

private slots:
    void step(qreal v);

private:
    QTimeLine *_timeline;
    qreal _value;
    int _position;
    QPointF _lastDrawPos;
    QFont _font;
    QPalette _palette;
    QString _text;
    QSizeF _size;
};

} // namespace CodeEdit

#endif // CODEEDITORANIMATOR_H
